<template tag="以下文档内容为hycli自动生成">
  <div style="height: 100%">
    <div style="margin:0.8rem;"><h5 style="display:inline">用户账户</h5><span style="margin-left: 0.5rem; color:#999"> </span>
    </div>
    <hr style="margin-top:0;color:#999"/>
<div class="query">
    
    <el-form :model="form_aaasz" inline >
        <!-- 日期控件个数： 0 -->
        <!--员工 下拉控件 -->
        <el-form-item>
            <el-select   @change="onChange_staff_id"   v-model="form_aaasz.staff_id" style="width: 100px" filterable clearable placeholder="员工">
                <el-option v-for="item in staff_idList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!-- 控件个数：[{"index":36,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar(32)","name":"varchar","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","l","le","c","u","v","DN","#like"],"desc":{"raw":"姓名","name":"姓名"}} {"index":37,"raw":"user_name","name":"user_name","cname":"UserName","type":{"raw":"varchar(32)","name":"varchar","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["UNQ(unq_sso_user,2)","q","l","le","c","u","v"],"desc":{"raw":"登录名","name":"登录名"}} {"index":38,"raw":"mobile","name":"mobile","cname":"Mobile","type":{"raw":"varchar(12)","name":"varchar","len":12,"dlen":0},"defValue":"","allowNull":true,"constraints":["q","l","le","c","u","v"],"desc":{"raw":"手机号","name":"手机号"}}] -->
         <el-form-item>
            <el-input clearable style="width: 180px" v-model="form_aaasz.single_text_value" maxlength="32"
                placeholder="关键字" >
                <template #prepend>
                    <el-select v-model="form_aaasz.single_text_name" placeholder="查询类型" style="width:84px;">
                        <el-option
                        v-for="item in multiQueryText"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                      </el-select>
                  </template>
            </el-input>
        </el-form-item>

        <span class="ddl">
        </span>
        <el-form-item>
            <el-space wrap>
                <el-button type="primary" icon="Search" @click="onQuery(true)">查询</el-button>
                <el-button :type="$js.page.tagColor(0)"  icon="Plus"  @click="show_cmpnt_aaatd">添加用户</el-button>
            </el-space>
        </el-form-item>
        

        <!-- xtabs -->
        

    </el-form>
</div>
<div>
   <aabed ref="cmpnt_aabed" @onsaved="onQuery"></aabed>
   <aabee ref="cmpnt_aabee" @onsaved="onQuery"></aabee>
   <aaatd ref="cmpnt_aaatd" @onsaved="onQuery"></aaatd>
   <aaatb ref="cmpnt_aaatb" @onsaved="onQuery"></aaatb>
   <aaatc ref="cmpnt_aaatc" @onsaved="onQuery"></aaatc>
</div>
<div class="list">
    <el-table :data="dataList_aaasz"
    
    v-loading="conf.loading" stripe  style="width: 100%;height:calc(100vh - 160px)"
         empty-text="无数据">le
<el-table-column width="24px" type="expand">
    <template #default="view">
        <el-row :gutter="24">
            <el-col :span="5" class="text-right" style="min-height:26px">用户编号:</el-col>
            <el-col :span="7" v-text="view.row.le_user_id" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">员工:</el-col>
            <el-col :span="7" v-text="view.row.staff_id_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">姓名:</el-col>
            <el-col :span="7" v-text="view.row.le_name" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">登录名:</el-col>
            <el-col :span="7" v-text="view.row.le_user_name" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">手机号:</el-col>
            <el-col :span="7" v-text="view.row.le_mobile" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">代理人:</el-col>
            <el-col :span="7" v-text="view.row.le_tenant_id" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">微信openid:</el-col>
            <el-col :span="7" v-text="view.row.le_wx_openid" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">状态:</el-col>
            <el-col :span="7" v-text="view.row.status_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">最近登录:</el-col>
            <el-col :span="7" v-text="view.row.le_last_login_time" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">最大错误次数:</el-col>
            <el-col :span="7" v-text="view.row.le_max_failed_cnt" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">当前错误次数:</el-col>
            <el-col :span="7" v-text="view.row.le_curr_failed_cnt" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">最近登录失败时间:</el-col>
            <el-col :span="7" v-text="view.row.le_last_failed_time" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">扩展参数:</el-col>
            <el-col :span="7" v-html="view.row.le_ext_params||'-'" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">创建时间:</el-col>
            <el-col :span="7" v-text="view.row.le_create_time" style="min-height:26px" ></el-col>
        </el-row>
    </template>
</el-table-column>
        
        	<!--user_id text -->
        <el-table-column  show-overflow-tooltip    align="center" label="用户编号" >
            <template #default="scope">
                  <span>{{ scope.row.user_id||'-' }}</span>
              </template>
        </el-table-column>
        	<!--name text -->
        <el-table-column  show-overflow-tooltip    align="center" label="姓名" >
            <template #default="scope">
                  <span>{{ scope.row.name||'-' }}</span>
              </template>
        </el-table-column>
        	<!--user_name text -->
        <el-table-column  show-overflow-tooltip    align="center" label="登录名" >
            <template #default="scope">
                  <span>{{ scope.row.user_name||'-' }}</span>
              </template>
        </el-table-column>
        	<!--mobile text -->
        <el-table-column  show-overflow-tooltip    align="center" label="手机号" >
            <template #default="scope">
                  <span>{{ scope.row.mobile||'-' }}</span>
              </template>
        </el-table-column>
        	<!--status switch -->
        <el-table-column     align="center" label="状态">
            <template #default="scope">
                <el-switch  @change="onstatusSwitchChange(scope.row,$event)"  v-model="scope.row.status_switch" />
            </template>
        </el-table-column>
        	<!--last_login_time date -->
        <el-table-column  show-overflow-tooltip    align="center" label="最近登录" >
            <template #default="scope">
                  <span>{{ scope.row.last_login_time||'-' }}</span>
              </template>
        </el-table-column>
        	<!--create_time date -->
        <el-table-column  show-overflow-tooltip    align="center" label="创建时间" >
            <template #default="scope">
                  <span>{{ scope.row.create_time||'-' }}</span>
              </template>
        </el-table-column>

<el-table-column fixed="right" align="center" label="操作" width="112">
    <template #default="scope">
        <div class="opts">
            <el-button   type="text" @click="show_cmpnt_aaatb(scope.row)" >详情 </el-button>
            <el-button   type="text" @click="show_cmpnt_aaatc(scope.row)" >修改 </el-button>
        </div>
    </template>
</el-table-column>
    </el-table>
    <el-pagination :currentPage="form_aaasz.pi" :page-size="form_aaasz.ps"
        style="position: absolute; right: 30px;bottom:6px;" :page-sizes="[10,15,20,30, 50, 100]" :background="false" small
        layout="total,sizes,prev, pager, next, jumper" :total="total_aaasz" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
</div>
  </div>
</template>
<script>
// 添加
import aabed from "@/views/sso/user/user_role.add"
// 编辑
import aabee from "@/views/sso/user/user_role.edit"
// 添加用户
import aaatd from "@/views/sso/user/user_account.add"
// 详情
import aaatb from "@/views/sso/user/user_account.view"
// 修改
import aaatc from "@/views/sso/user/user_account.edit"



export default {
components: {
    aabed,
    aabee,
    aaatd,
    aaatb,
    aaatc,
},
data() {
  return {
    shortcuts: this.$js.page.latestDays(),
    cmpnt_funcs:{},
    conf: {
      loading: false,
      progressColor: this.$theia.env.conf.progress || []
    },
    ganttIdx: -1,
        form_aaasz: {
            pi: 1,
            ps: 15,
            disabled:false,
            single_date_range_name:"",
            single_date_range_value:[],
            single_text_name:"",
            single_text_value:"",
            staff_id:"",
            name:"",
            user_name:"",
            mobile:"",
            },
            staff_idList:[],
            statusList:[],
            dataList_aaasz:[],
            multiQueryDateRange:[],
            multiQueryText:[{label:"姓名",value:"name"},{label:"登录名",value:"user_name"},{label:"手机号",value:"mobile"},],
            total_aaasz:0,
            note_dataList:[],
};
  },
mounted() {
  this.loadEnums_aaasz()
  this.form_aaasz.single_date_range_name = (this.multiQueryDateRange[0]||{}).value
  this.form_aaasz.single_text_name = (this.multiQueryText[0]||{}).value
  this.cmpnt_funcs["aabed"] = this.show_cmpnt_aabed
  this.cmpnt_funcs["aabee"] = this.show_cmpnt_aabee
  this.cmpnt_funcs["aaatd"] = this.show_cmpnt_aaatd
  this.cmpnt_funcs["aaatb"] = this.show_cmpnt_aaatb
  this.cmpnt_funcs["aaatc"] = this.show_cmpnt_aaatc

  this.form_aaasz = Object.assign(this.form_aaasz,this.$route.params)
  this.queryData_aaasz ()
    },
methods: {
  ganttChange(id) {
      this.ganttIdx = id
    },

queryData_aaasz(mform = {},nform={}){
    //构建查询参数
    let queryForm = Object.assign({},this.form_aaasz)
    queryForm = Object.assign(queryForm,nform||{})
    
    //处理多个日期选择
    queryForm[this.form_aaasz.single_date_range_name] = this.form_aaasz.single_date_range_value
    queryForm[this.form_aaasz.single_text_name] = this.form_aaasz.single_text_value
   
    //处理日期范围选择

    queryForm[this.form_aaasz.single_date_range_name] = null
    queryForm.single_date_range_value = null
    queryForm.single_date_range_name = null

    queryForm.single_text_value = null
    queryForm.single_text_name = null
 
    //处理关联表user_account user_account user_account
   
    //发送查询请求
    let that = this
    that.conf.loading = true
    //构建统计查询
  //数据查询
  this.$theia.http.get("/sso/user/account/query",queryForm).then(res=>{
      if((res.items||[]).length < (queryForm.ps||10)){
        that.form_aaasz.disabled = true
      }
      that.conf.loading = false
      that.dataList_aaasz = res.items||[]
      that.total_aaasz = res.count
      that.resetItemData_aaasz(that,that.dataList_aaasz)
    });
  },

  resetItemData_aaasz(that,lst){
    lst.forEach(item => {
      item.__raw = Object.assign({}, item)
    item.staff_id_label = that.$theia.enum.getName("staff_info",item.staff_id)
    item.status_label = that.$theia.enum.getName("status",item.status)
    item.user_id_progress = item.user_id
    item.staff_id_progress = item.staff_id
    item.name_progress = item.name
    item.user_name_progress = item.user_name
    item.mobile_progress = item.mobile
    item.tenant_id_progress = item.tenant_id
    item.wx_openid_progress = item.wx_openid
    item.status_switch = item.status == 0
    item.last_login_time_progress = item.last_login_time
    item.max_failed_cnt_progress = item.max_failed_cnt
    item.curr_failed_cnt_progress = item.curr_failed_cnt
    item.last_failed_time_progress = item.last_failed_time
    item.ext_params_progress = item.ext_params
    item.create_time_progress = item.create_time
    item.le_user_id = item.user_id
    item.le_staff_id = item.staff_id
    item.le_name = item.name
    item.le_user_name = item.user_name
    item.le_mobile = item.mobile
    item.le_tenant_id = item.tenant_id
    item.le_wx_openid = item.wx_openid
    item.le_status = item.status
    item.le_last_login_time = that.$theia.str.dateFormat(item.last_login_time,'MM/dd HH:mm')
    item.le_max_failed_cnt = item.max_failed_cnt
    item.le_curr_failed_cnt = item.curr_failed_cnt
    item.le_last_failed_time = that.$theia.str.dateFormat(item.last_failed_time,'MM/dd HH:mm')
    item.le_ext_params = item.ext_params
    item.le_create_time = that.$theia.str.dateFormat(item.create_time,'MM/dd')
    item.last_login_time = that.$theia.str.dateFormat(item.last_login_time,'MM/dd HH:mm')
    item.create_time = that.$theia.str.dateFormat(item.create_time,'MM/dd')
    if(item.children){
      that.resetItemData_aaasz(that,item.children)
    }
  });
  },
  onstatusSwitchChange(xfrom,v) {
      let form = {}
      form.status = v == true? 0 : 1;
      form.user_id = xfrom.user_id
      let that = this
      this.$theia.http.post("/sso/user/account/switch",form).then(res=>{
        that.$notify.success({title: '成功',message: '修改状态成功',duration:5000})
      }).catch(res=>{
        v = !v
        let code = ((res||{}).response||{}).status||0
        let msg = `修改状态失败(${code})`
        that.$notify.error({title: '失败',message: msg,duration:5000})
      });
  }, 
    onChange_staff_id(val){
      this.staff_idList = this.$theia.enum.get("staff_info",val)
      this.form_aaasz.staff_id = null
    },
    loadEnums_aaasz(){
        //员工
        this.staff_idList = this.$theia.enum.get("staff_info","","" ,false,"")
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
    },

  handleSizeChange(ps){
    this.form_aaasz.ps = ps
    this.onQuery(true)
  },
  handleCurrentChange(pi){
    this.form_aaasz.pi = pi
    this.onQuery()
  },
  onQuery(refresh){
    if(refresh){
      this.form_aaasz.pi = 1
    }
    this.queryData_aaasz ()
  },
show_cmpnt(cmd,row){
  if(this.cmpnt_funcs[cmd]){
    this.cmpnt_funcs[cmd](row)
  }
},
  //详情
  show_cmpnt_aaatb(fm = {}){
    let query = {} 
    query.user_id = fm.user_id|| fm.le_user_id 
    query.staff_id = fm.staff_id|| fm.le_staff_id 
    query.name = fm.name|| fm.le_name 
    query.user_name = fm.user_name|| fm.le_user_name 
    query.mobile = fm.mobile|| fm.le_mobile 
    query.password = fm.password|| fm.le_password 
    query.tenant_id = fm.tenant_id|| fm.le_tenant_id 
    query.wx_openid = fm.wx_openid|| fm.le_wx_openid 
    query.status = fm.status|| fm.le_status 
    query.last_login_time = fm.last_login_time|| fm.le_last_login_time 
    query.max_failed_cnt = fm.max_failed_cnt|| fm.le_max_failed_cnt 
    query.curr_failed_cnt = fm.curr_failed_cnt|| fm.le_curr_failed_cnt 
    query.last_failed_time = fm.last_failed_time|| fm.le_last_failed_time 
    query.ext_params = fm.ext_params|| fm.le_ext_params 
    query.create_time = fm.create_time|| fm.le_create_time 
    query.user_id = fm.user_id

      //2023.4.18添加---

    query.$title="详情"
    this.$refs.cmpnt_aaatb.show(query)
  },
  //添加用户
  show_cmpnt_aaatd(fm = {}){
    let query = {} 
    query.staff_id = fm.staff_id|| fm.le_staff_id 
    query.name = fm.name|| fm.le_name 
    query.user_name = fm.user_name|| fm.le_user_name 
    query.mobile = fm.mobile|| fm.le_mobile 
    query.password = fm.password|| fm.le_password 
    query.status = fm.status|| fm.le_status 
    query.user_id = fm.user_id

      //2023.4.18添加---
    query.status = "0"

    query.$title="添加用户"
    this.$refs.cmpnt_aaatd.show(query)
  },
  //修改
  show_cmpnt_aaatc(fm = {}){
    let query = {} 
    query.staff_id = fm.staff_id|| fm.le_staff_id 
    query.name = fm.name|| fm.le_name 
    query.user_name = fm.user_name|| fm.le_user_name 
    query.mobile = fm.mobile|| fm.le_mobile 
    query.status = fm.status|| fm.le_status 
    query.user_id = fm.user_id

      //2023.4.18添加---

    query.$title="修改"
    this.$refs.cmpnt_aaatc.show(query)
  },
},
};
</script>
<style>
.el-dialog{
  border-radius:5px !important
}
</style>
<style scoped>
.el-form-item {
  margin-right: 10px !important;
}

.opts .el-button--small {
  margin-left: 0px;
  padding-left: 0px;
  margin-right: 4px;
}

/deep/.el-table td.el-table__cell div {
  vertical-align: middle;
}
/deep/.el-button+.el-dropdown{
  margin-left:0px;
}
/deep/.el-button+.el-button{
  margin-left:0px;
}
.el-button{
  padding-left: 6px !important;
  padding-right: 6px !important;
}
.blist {
  margin-bottom: 8px;
  width: 100%;
}

.blist .el-radio-group {
  margin-right: 8px;
}

.ddl {
  margin-bottom: 8px;
  width: 100%;

}

.ddl .el-dropdown {
  margin-right: 8px;
}

.listbar {
  margin-bottom: 8px;
  text-align: center;
}
 .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
  font-size: 0.65rem;
}
/deep/.el-button--small{
  padding: 5px 4px;
}

.prepend /deep/.el-input__wrapper{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
.prepend+/deep/.el-date-editor{
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-left:0;
}

</style>